/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Model;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;


/**
 *
 * @author Sik
 */

@Entity
@Table(name = "attribution")
@XmlRootElement
@NamedQueries(
{
    @NamedQuery(name = "Attribution.findAll", query = "SELECT a FROM Attribution a"),
    @NamedQuery(name = "Attribution.findByZoneidZone", query = "SELECT a FROM Attribution a WHERE a.attributionPK.zoneidZone = :zoneidZone"),
    @NamedQuery(name = "Attribution.findByUtilisateuridUtilisateur", query = "SELECT a FROM Attribution a WHERE a.attributionPK.utilisateuridUtilisateur = :utilisateuridUtilisateur"),
    @NamedQuery(name = "Attribution.findByDate", query = "SELECT a FROM Attribution a WHERE a.date = :date"),
    @NamedQuery(name = "Attribution.findByStatut", query = "SELECT a FROM Attribution a WHERE a.statut = :statut")
})
public class Attribution implements Serializable
{
    @Basic(optional =     false)
    @Column(name = "date")
    @Temporal(TemporalType.DATE)
    private Date date;
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected AttributionPK attributionPK;
    @Column(name = "statut")
    private String statut;
    @JoinColumn(name = "Zone_idZone", referencedColumnName = "idZone", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Zone zone;
    @JoinColumn(name = "Utilisateur_idUtilisateur", referencedColumnName = "idUtilisateur", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Utilisateur utilisateur;
   

    public Attribution()
    {
    }

    public Attribution(AttributionPK attributionPK)
    {
        this.attributionPK = attributionPK;
    }

    public Attribution(AttributionPK attributionPK, Date date)
    {
        this.attributionPK = attributionPK;
        this.date = date;
    }

    public Attribution(int zoneidZone, int utilisateuridUtilisateur)
    {
        this.attributionPK = new AttributionPK(zoneidZone, utilisateuridUtilisateur);
    }

    public AttributionPK getAttributionPK()
    {
        return attributionPK;
    }

    public void setAttributionPK(AttributionPK attributionPK)
    {
        this.attributionPK = attributionPK;
    }

    public String getStatut()
    {
        return statut;
    }

    public void setStatut(String statut)
    {
        this.statut = statut;
    }

    public Utilisateur getUtilisateur()
    {
        return utilisateur;
    }

    public void setUtilisateur(Utilisateur utilisateur)
    {
        this.utilisateur = utilisateur;
    }

    public Zone getZone()
    {
        return zone;
    }

    public void setZone(Zone zone)
    {
        this.zone = zone;
    }

    @Override
    public int hashCode()
    {
        int hash = 0;
        hash += (attributionPK != null ? attributionPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object)
    {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Attribution))
        {
            return false;
        }
        Attribution other = (Attribution) object;
        if ((this.attributionPK == null && other.attributionPK != null) || (this.attributionPK != null && !this.attributionPK.equals(other.attributionPK)))
        {
            return false;
        }
        return true;
    }

    @Override
    public String toString()
    {
        return "Model.Attribution[ attributionPK=" + attributionPK + " ]";
    }

    public Date getDate()
    {
        return date;
    }

    public void setDate(Date date)
    {
        this.date = date;
    }
}
